﻿using System.ComponentModel.DataAnnotations;
namespace MvcCart.Models
{
    public class Cart
    {
        public int Id { get; set; } // id

        [Required(ErrorMessage = "购物车ID必填")]
        [StringLength(20, MinimumLength = 3, ErrorMessage = "3-20个字符")]
        [Display(Name = "购物车ID")]
        public String? CartId { get; set; } // 购物车id

        [Required(ErrorMessage = "商品ID必填")]
        [StringLength(20, MinimumLength = 3, ErrorMessage = "3-20个字符")]
        [Display(Name = "商品名称")]
        public String? ProductId { get; set; } // 商品id

        [Required(ErrorMessage = "商品数量必填")]
        [Range(1, 10000, ErrorMessage = "1-10000之间")]
        [Display(Name = "商品数量")]
        public int? ProductNum { get; set; } //商品数量

        [Required(ErrorMessage = "商品价格必填")]
        [Range(1, 10000, ErrorMessage = "1-10000之间")]
        [Display(Name = "商品价格")]
        [DataType(DataType.Currency)]
        public decimal Price { get; set; } //商品价格

        [Required(ErrorMessage = "用户ID必填")]
        [StringLength(20, MinimumLength = 3, ErrorMessage = "3-20个字符")]
        [Display(Name = "用户名")]
        public String? UserId { get; set; } // 用户id

        [Required(ErrorMessage = "创建日期必填")]
        [Display(Name = "创建日期")]
        [DataType(DataType.Date)]
        public DateTime Createtime { get; set; } //创建日期






    }
}
